package com.zhj.leetcode;

/**
 * 力扣62 不同路径
 * @author zhj
 */
public class Test62 {
    public static void main(String[] args) {
        System.out.println(uniquePaths(3,6));
    }

    public static int uniquePaths(int m, int n) {
        // 初始值
        int[][] dp = new int[m][n];
        dp[0][0] = 1;
        for (int i = 0; i < m; i++) {
            for (int j = 0; j < n; j++) {
                if (i-1 >= 0 && i-1 < m) {
                    dp[i][j] += dp[i-1][j];
                }
                if (j-1 >= 0 && j-1 < n) {
                    dp[i][j] += dp[i][j-1];
                }
            }
        }
        return dp[m-1][n-1];
    }
}
